# =================conding: utf-8
"""
================================================================================

Author : Administrator
Created  on : 2020/11/22

E-mail: zh13997821732@163.com


================================================================================

"""
# 1.使用两种方式，定义一个空字典
dic = {}
dic1 = dict()

# 2.定义一个字典，有三对键值对（内容：姓名，年龄，地址）
dic = {'姓名': 'zh', '年龄': '25', '地址': 'china'}`
print(dic)

# 3.定义一个字典，分别使用两种方法，获取某个键对应的值
dic = {'姓名': 'zh', '年龄': '25', '地址': 'china'}
print(dic['姓名'])
print(dic.get('年龄'))

# 4.定义一个字典，修改某个键对应的值
dic = {'姓名': 'zh', '年龄': '25', '地址': 'china'}
dic['姓名'] = 'sasa'
print(dic)

# 5.定义一个字典，取出字典中所有的键和值
dic = {'姓名': 'zh', '年龄': '25', '地址': 'china'}
print(dic.items())

# 6.定义一个字典，向字典中添加键值对
dic = {'姓名': 'zh', '年龄': '25', '地址': 'china'}
dic['11'] = 22
print(dic)

# 7.定义两个字典，a 和 b ，将a字典中的所有键值对加入到b字典中
dic1 = {'姓名': 'zh', '年龄': '25', '地址': 'china'}
dic2 = {'身高': '180'}
dic1.update(dic2)
print(dic1)

# 8.定义一个字典，删除某个键对应的键值对
dic1 = {'姓名': 'zh', '年龄': '25', '地址': 'china'}
dic1.pop('姓名')
print(dic1)

# 9.定义一个字典，从末尾开始，删除一对键值对
dic1 = {'姓名': 'zh', '年龄': '25', '地址': 'china'}
dic1.popitem()
print(dic1)

